import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import Category from "../views/Category";
import Details from "../views/Details";
import My from "../views/My"
import login from "../views/login"
import CategoryContent from "../views/CategoryContent"

// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

Vue.use(VueRouter)

const routes = [
  {
    path: '',
    name: 'Home',
    component: Home
  },
  {
    path: '/Category',
    name: 'Category',
    component: Category
  },
  {
    path: '/Details',
    name: 'Details',
    component: Details
  },
  {
    path: '/My',
    name: 'My',
    component: My
  },
   {
    path: '/login',
    name: 'login',
    component: login
  },
  {
    path: '/CategoryContent',
    name: 'CategoryContent',
    component: CategoryContent
  }
  // {
  //   path: '/about',
  //   name: 'About',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  // }
]

const router = new VueRouter({
  mode: 'history',
  base: '/dist/',
  routes
})

export default router
